<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>jQuery AJAX</title>
    <script src="/jquerydemo/script/jquery-3.3.1.js"></script>
    <script>
        $().ready(function () {
            // $("#submit").click(function () {
            //     let username = $("#username").val();  // ES 6
            //     let password = $("#password").val();
            //     console.log(username)
            //
            //     $.ajax({
            //         url:"/jquerydemo/json/epms.json", // 请求的url地址
            //         method:"GET",  // http 请求方法
            //         contentType: "application/x-www-form-urlencoded", // 数据类型
            //         data:{"username": username, "pswd": password},  // 数据JavaScript 对象 JScript, JavaScript, JsonScript
            //         success : function(response, status) { // 异步请求成功过后的回调函数
            //             console.log(status)
            //             for (obj in response) {
            //                 console.log(response[obj].username + "的性别是：" + response[obj].gender)
            //             }
            //
            //             // 登录成功，跳转到主页面（百度）
            //             if (status == "success") {
            //                 location.href = "https://www.baidu.com";
            //             }
            //         }
            //     })
            //
            // });
        $("#submit02").on("click", function () {
            let username = $("#username02").val();
            let password = $("#password02").val();

            $.post("/jquerydemo/json/epms.json",
                {"username": username, "pswd": password},
                function (resp, status, xhr) {
                    console.log(status)
                    console.log(resp)
                    console.log(xhr)
                })
        });
        })
    </script>
</head>
<body>
    <form id="login">
        用户名<input type="text" name="username" id="username"  />
        密&nbsp;&nbsp;码<input type="password" name="password" id="password" />
        <input type="button" value="登录" id="submit">
    </form>
    <hr />
    <form id="login02">
        用户名<input type="text" name="username" id="username02"  />
        密&nbsp;&nbsp;码<input type="password" name="password" id="password02" />
        <input type="button" value="登录" id="submit02">
    </form>
</body>
</html>